<?php

use Faker\Factory as Faker;
use App\Models\ChannelVisitDay;
use App\Repositories\ChannelVisitDayRepository;

trait MakeChannelVisitDayTrait
{
    /**
     * Create fake instance of ChannelVisitDay and save it in database
     *
     * @param array $channelVisitDayFields
     * @return ChannelVisitDay
     */
    public function makeChannelVisitDay($channelVisitDayFields = [])
    {
        /** @var ChannelVisitDayRepository $channelVisitDayRepo */
        $channelVisitDayRepo = App::make(ChannelVisitDayRepository::class);
        $theme = $this->fakeChannelVisitDayData($channelVisitDayFields);
        return $channelVisitDayRepo->create($theme);
    }

    /**
     * Get fake instance of ChannelVisitDay
     *
     * @param array $channelVisitDayFields
     * @return ChannelVisitDay
     */
    public function fakeChannelVisitDay($channelVisitDayFields = [])
    {
        return new ChannelVisitDay($this->fakeChannelVisitDayData($channelVisitDayFields));
    }

    /**
     * Get fake data of ChannelVisitDay
     *
     * @param array $postFields
     * @return array
     */
    public function fakeChannelVisitDayData($channelVisitDayFields = [])
    {
        $fake = Faker::create();

        return array_merge([
            'channel_id' => $fake->randomDigitNotNull,
            'visit_date' => $fake->word,
            'visit_num' => $fake->randomDigitNotNull,
            'status' => $fake->randomDigitNotNull,
            'updated_at' => $fake->word,
            'created_at' => $fake->word
        ], $channelVisitDayFields);
    }
}
